import {
    getMailList
} from '@/services/setting/mailSubscribe';


export default {
    namespace: 'mailSubscribe',
    state: {
        mailList: [],
        pagination: {
            pageSize: 10,
            current: 1,
            total: 0
        }
    },
    effects: {
        // 获取邮件列表
        *fetchMailList({ payload }, { put, call }) {
            const result = yield call(getMailList, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        mailList: result.data.rows,
                        pagination: {
                            current: result.data.pageNo,
                            pageSize: result.data.pageSize,
                            total: result.data.total
                        }
                    }
                });
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
